// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  try {
    const {OPENID} = cloud.getWXContext();
    const result = await cloud.openapi.subscribeMessage.send({
        touser: OPENID,
        page: 'index',
        lang: 'zh_CN',
        data: {
          thing1: {
            value: event.thing1
          },
          thing2: {
            value: event.thing2
          },
          time3: {
            value: event.time3
          }
        },
        templateId: 'O_AhAQijzT0T8IQUCtHa-casQsPlXN2T6iOSHY1ddYc',
        miniprogramState: 'developer'
      })
    return result
  } catch (err) {
    return err
  }
}